<%--
  Created by IntelliJ IDEA.
  User: t410
  Date: 2017/7/3
  Time: 15:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	response.setHeader("Pragma", "no-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", 0);
%>

<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="<%=basePath%>js/jslib/jquery/jquery-2.1.1.js"></script>

    <script type="text/javascript">
    	function loadData(){
    	    alert("in function");
    		var actionUrl="<%=basePath%>"+"UrlMapping/handleJson.action";
    		var params=JSON.stringify([{
    			firstName:"zhang",
    			secondName:"san"
    		},{
    			firstName:"li",
    			secondName:"si"
    		}]);
    		$.ajax({
    			type:'post',
    			url:actionUrl,
    			data:params,
    			dataType:'json',//后台返回的数据类型
    			cache:false,
    			contentType:"application/json;charse=UTF-8",//表示发送的内容为json
    			error:function(textStatus,errorThrown){
    				  	alert("系统请求错误: " + textStatus);
    			},
    			success:function(data,textStatus){
    				alert("请求成功==>姓名:"+data.firstName+"--"+data.secondName);
    			}
    		});
    	}
    </script>
</head>
<body>
	 <div style="padding:5px 0;">
        <p>SpringMVC @RequestBody 接收Json数组对象</p>
		<a href="javascript:void(0);"  onclick="loadData();">@RequestBody 接收Json数组对象</a>
	</div>

</body>
</html>
